package com.example.miniappssm.service.serviceImpl;

import com.example.miniappssm.bean.Admin;
import com.example.miniappssm.mapper.AdminMapper;
import com.example.miniappssm.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    AdminMapper adminMapper;

    @Override
    public List<Admin> showAllAdmin() {
        return adminMapper.selectAllAdmin();
    }

    @Override
    public Admin showAdminByOpenid(String openid) {
        return adminMapper.selectAdminByOpenid(openid);
    }

    @Override
    public boolean openidIsInAdmins(String openid) {
        return adminMapper.selectAdminByOpenid(openid) != null;
    }

    @Override
    public void addAdmin(Admin admin) {
        adminMapper.insertAdmin(admin);
    }

    @Override
    public void removeAdminByOpenid(String openid) {
        adminMapper.deleteAdminByOpenid(openid);
    }

    @Override
    public void updateAdmin(Admin admin) {
        adminMapper.updateAdmin(admin);
    }
}
